package com.geologyoa.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.geologyoa.service.SystemManager;
import com.geologyoa.service.SystemManagerImpl;

public class CheckDwqk01Servlet extends HttpServlet  {
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
        doPost(request,response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		SystemManager sys=new SystemManagerImpl();
		String type = request.getParameter("type");
		String zzid = "";
		String dwid = "";
		String name = "";
		String zzType = "";
		Boolean flag = false;
		switch(Integer.parseInt(type)){
		case 1://根据名称查询是否存在该单位
			name=request.getParameter("DWQK0103");
			flag = sys.CheckDwqkByName(name);
			break;
		case 2://根据名称和id查询是否存在该单位
			dwid = request.getParameter("DWQK0101");
			name = request.getParameter("DWQK0103");
			flag = sys.CheckDwqkByIdAndName(Integer.parseInt(dwid), name);
			break;
		case 3://根据单位id和资质类型   查询资质表 是否存在该单位在该资质下的记录
			dwid = request.getParameter("DWQK0101");
			zzType = request.getParameter("DWZZ0104");
			flag = sys.CheckDwqkByIdAndZZType(Integer.parseInt(dwid), zzType);
			break;
		case 4://根据
			zzid = request.getParameter("DWZZ0101");
			dwid = request.getParameter("DWQK0101");
			zzType = request.getParameter("DWZZ0104");
			flag = sys.CheckDwqkByIdAndZZTypeExceptZZid(Integer.parseInt(zzid),Integer.parseInt(dwid), zzType);
		}
		response.getWriter().write(String.valueOf(flag));
		/*if(flag==true)
		{
			response.getWriter().write("true");
		}else{
			response.getWriter().write("false");
		}*/
	}
	
}
